<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>管理员</title>
    <link href="__STATIC__/admin/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="__STATIC__/admin/css/style.css" />
    <link href="__STATIC__/admin/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace.min.css" />
    <link rel="stylesheet" href="__STATIC__/admin/font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="__STATIC__/admin/js/jquery-1.9.1.min.js"></script>
    <script src="__STATIC__/admin/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="__STATIC__/admin/assets/js/typeahead-bs2.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/js/lrtk.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/assets/laydate/laydate.js" type="text/javascript"></script>
</head>

<body>
<div class="crumbs">
    <ul>
        <li>
            <a class="active" href="javascript:;">角色列表</a>
        </li>
    </ul>
</div>
<div class="page-content clearfix">
    <div class="administrator">
        <div class="d_Confirm_Order_style">

            <!--操作-->
            <div class="border clearfix">
                <span class="l_f">
                    <a href="javascript:;" class="btn btn-warning"><i class="fa fa-plus"></i> 添加管理员</a>

                </span>
            </div>
            <!--管理员列表-->
            <div class="clearfix">
                <div class="table_menu_list">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th width="80px">编号</th>
                                <th width="250px">角色英文名称</th>
                                <th width="100px">角色中文名称</th>
                                <th width="70px">状态</th>
                                <th width="200px">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {foreach $roles as $item}
                            <tr>

                                <td>{$item.id}</td>
                                <td>{$item.name}</td>
                                <td>{$item.remark}</td>
                                <td>
                                    {if condition="$item.status==1"}
                                    <span class="label label-success radius">已启用</span>
                                    {else}
                                    <span class="label label-success radius">已停用</span>
                                    {/if}
                                </td>
                                <td>
                                    <a href="{:url('rbac/access',['id'=>$item.id])}" title="分配权限"
                                       class="btn btn-xs btn-success">分配权限</a>
                                    <a title="编辑"  href="{:url('rbac/editerole',['id'=>$item.id])}" class="btn btn-xs btn-info">
                                        <i class="fa fa-edit bigger-120"></i>
                                    </a>
                                    <a title="删除" href="javascript:;" data-id="{$item.id}"   class="btn btn-xs btn-warning role_del">
                                        <i class="fa fa-trash  bigger-120"></i>
                                    </a>
                                </td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="dataTables_info">共 2 条</div>
                </div>

            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //单行删除
    $('.role_del').on('click',function () {
        var that=$(this);

        layer.confirm('真的那么狠心吗?',{icon:3,title:'错误提示'},function (index) {
            del(that);
            layer.close(index);
        });
    });
    function del(that){
        var id=$(that).data('id');
        var url="{:url('rbac/delrole')}";
        var data={id:id};
        $.post(url,data,function (res) {
            if(res.status==1){
                $(that).parent().parent().remove();
                layer.msg('删除成功',{
                    title:'提示',
                    icon:6
                })
            }else{
                layer.msg('删除失败',{
                    title:'提示',
                    icon:4
                })
            }
        },'json');
    };


    /*用户-停用*/
    function member_stop(obj, id) {
        layer.confirm('确认要停用吗？', function(index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="fa fa-close bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
            $(obj).remove();
            layer.msg('已停用!', {
                icon: 5,
                time: 1000
            });
        });
    }
    /*用户-启用*/
    function member_start(obj, id) {
        layer.confirm('确认要启用吗？', function(index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="fa fa-check  bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
            $(obj).remove();
            layer.msg('已启用!', {
                icon: 6,
                time: 1000
            });
        });
    }
</script>
</body>
</html>